package cc.marcio.systems.seven.load;

import cc.marcio.systems.seven.dao.DaoFactory;
import cc.marcio.systems.seven.model.Action;
import cc.marcio.systems.seven.model.Planet;
import cc.marcio.systems.seven.model.PlanetId;
import cc.marcio.systems.seven.model.Round;
import cc.marcio.systems.seven.model.User;

public class CombatLoad implements DataBaseLoad {

	public void load() {
		Round round = DaoFactory.getRoundDao().get(1L);
		
		User user = DaoFactory.getUserDao().get(1L);
		PlanetId planetId = new PlanetId();
		planetId.setRound(round);
		planetId.setUser(user);
		Planet planet = new Planet();
		planet.setId(planetId);
		planet = DaoFactory.getPlanetDao().findOneByExample(planet);
		
		Action attack = new Action(planet);
		attack.setAction(Action.ACTION_ATTACK);
		attack.setGalaxia(5);
		attack.setSector(1);
		attack.setSlot(2);
		attack.setName("atacante");
		attack.setShips(1200);
		attack.setSquad(5);
		attack.setTickAction(round.getCurrentTick());
		attack.setTickArrive(7);
		DaoFactory.getActionDao().save(attack);
		
		user = DaoFactory.getUserDao().get(2L);
		planetId = new PlanetId();
		planetId.setRound(round);
		planetId.setUser(user);
		planet = new Planet();
		planet.setId(planetId);
		planet = DaoFactory.getPlanetDao().findOneByExample(planet);
		
		Action defense = new Action(planet);
		defense.setAction(Action.ACTION_DEFENSE);
		defense.setGalaxia(4);
		defense.setSector(4);
		defense.setSlot(1);
		defense.setName("defensor");
		defense.setShips(500);
		defense.setSquad(2);
		defense.setTickAction(round.getCurrentTick());
		defense.setTickArrive(7);
		DaoFactory.getActionDao().save(defense);
		
		attack = new Action(planet);
		attack.setAction(Action.ACTION_ATTACK);
		attack.setGalaxia(5);
		attack.setSector(1);
		attack.setSlot(2);
		attack.setName("atacante");
		attack.setShips(1200);
		attack.setSquad(5);
		attack.setTickAction(round.getCurrentTick());
		attack.setTickArrive(7);
		DaoFactory.getActionDao().save(attack);
				
		user = DaoFactory.getUserDao().get(3L);
		planetId = new PlanetId();
		planetId.setRound(round);
		planetId.setUser(user);
		planet = new Planet();
		planet.setId(planetId);
		planet = DaoFactory.getPlanetDao().findOneByExample(planet);
		
		defense = new Action(planet);
		defense.setAction(Action.ACTION_DEFENSE);
		defense.setGalaxia(4);
		defense.setSector(9);
		defense.setSlot(10);
		defense.setName("defensor");
		defense.setShips(500);
		defense.setSquad(2);
		defense.setTickAction(round.getCurrentTick());
		defense.setTickArrive(5);
		DaoFactory.getActionDao().save(defense);
				
		attack = new Action(planet);
		attack.setAction(Action.ACTION_ATTACK);
		attack.setGalaxia(5);
		attack.setSector(12);
		attack.setSlot(12);
		attack.setName("atacante");
		attack.setShips(1200);
		attack.setSquad(5);
		attack.setTickAction(round.getCurrentTick());
		attack.setTickArrive(7);
		DaoFactory.getActionDao().save(attack);		
	}

}
